home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
163_02
/
strncpy.c
< prev
next >
Wrap
Text File
|
1988-01-30
|
512b
|
12 lines
/*
** copy s2 to s1, truncating or null padding as necessary to create a string
** n characters long
*/
strncpy(s1, s2, n) char *s1, *s2; int n; {
char *strncpy;
strncpy = s1;
while(n--) if(!(*s1++ = *s2++)) break;
while(n-- > 0) *s1++ = 0;
return strncpy;
}